package com.hsp.codeblock;

public class CodeBlock01 {
    public static void main(String[] args) {
        Movie movie = new Movie("你好，李焕英");
        System.out.println("------------------");
        Movie movie1 = new Movie("金刚大战哥斯拉", 30, "sss");
    }
}



class Movie{
    private String name;
    private double price;
    private String director;

    //当我们不管调用那个构造器创建对象都会现调用代码块的内容
    //代码块的调用优先级高于构造器
    {
        System.out.println("电影屏幕打开了");
        System.out.println("广告开始了");
        System.out.println("电影正式开始");
    }

    public Movie(String name) {
        System.out.println("Movie(String name)被调用");
        this.name = name;
    }

    public Movie(String name, double price) {
        System.out.println("");
        this.name = name;
        this.price = price;
    }

    public Movie(String name, double price, String director) {
        System.out.println("Movie(String name, double price, String director)被调用");
        this.name = name;
        this.price = price;
        this.director = director;
    }
}